/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.validator;

import com.minierp.model.EnterpriseInfo;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class EnterpriseInfoValidator implements Validator {
	public boolean supports(Class clazz) {
		return EnterpriseInfo.class.isAssignableFrom(clazz);
	}

	public void validate(Object obj, Errors errors) {
		EnterpriseInfo form = (EnterpriseInfo) obj;
		if (form.getDbBackupFolder() != null
				&& form.getDbBackupFolder().indexOf(" ") != -1) {
			errors.rejectValue("dbBackupFolder", "", "『数据备份目录』不能包含空格字符。");
		} else if (form.getShortName() != null
				&& !form.getShortName().equals("")) {
			if (form.getPrintFoot() != null
					&& form.getPrintFoot().length() >= 200) {
				errors.rejectValue("printFoot", "", "『单据打印页脚』不能超过200个字。");
			} else if (form.getPageSize() <= 0) {
				errors.rejectValue("pageSize", "", "『记录显示行数』必须大于0。");
			}
		} else {
			errors.rejectValue("shortName", "", "『公司简称』将作为手机短信的签名档，不能为空。");
		}

	}
}